package com.wzh.yebServe.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzh.yebServe.mapper.UserRoleMapper;
import com.wzh.yebServe.pojo.ResultBean;
import com.wzh.yebServe.pojo.UserRole;
import com.wzh.yebServe.service.IUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author wzh
 * @create 2022/11/19 15:45
 * @Description:
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole>  implements IUserRoleService {
    @Autowired
    private UserRoleMapper userRoleMapper;

    @Override
    public ResultBean updateUserRole(Integer userId, Integer[] rids) {
        userRoleMapper.delete(new QueryWrapper<UserRole>().eq("adminId",userId));
        Integer integer = userRoleMapper.updateUserRole(userId, rids);
        if (integer==rids.length){
            return ResultBean.success("更新成功");
        }
        return ResultBean.error("更新失败");
    }
}
